<?php
	class VideoFieldType extends GigaFieldType
	{
		function onModelInitialize(GigaAppModel $model)
		{
			$videoFields = $model->getFields('type',"video");
			$configs = array();
			foreach($videoFields as $videoField)
			{
				$defaultconfig = array('removeOnEmpty'=>true,'dir'=>WWW_ROOT.'uploads'.DS.'videos'.DS,"mediaTypes"=>array("Video"=>array('empty'=>!$model->getFieldProperty($videoField,'required'))));
				$config = $model->getFieldProperty($videoField,'videoConfig'); 
				if(!is_array($config))
				{
					$config = array();
				}
				$config = am($defaultconfig,$config);
				$configs[$videoField] = $config;
			}
			if($videoFields)
			{
				$model->Behaviors->attach('Cms.Upload',$configs);
			}
		}
		
		function getFormOptions($form,$field,$options)
		{
			$options['type'] = "file";
			return $options;
		}
	}
?>